package com.example.lawyer.community;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lawyer.R;
import com.example.lawyer.databind.assembly.GeneralTopTitleData;
import com.example.lawyer.databind.assembly.MessageData;
import com.example.lawyer.databind.assembly.MessageListData;
import com.example.lawyer.databind.fargment.HomeCData;
import com.example.lawyer.databind.itemview.MessageListItemViewData;
import com.example.lawyer.databinding.FragmentPageHomeCBinding;
import com.example.lawyer.interfacecallback.PageHomeCCallback;
import com.example.lawyer.interfaceservice.PageHomeCService;

import java.util.List;


public class PageHomeC extends Fragment implements PageHomeCCallback {
    FragmentPageHomeCBinding viewDataBinding = null;
    LayoutInflater layoutInflater;
    ViewGroup viewGroup;
    HomeCData homeCData;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        layoutInflater = inflater;
        viewGroup = container;
        viewDataBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_page_home_c, container, false);

        viewDataBinding.setHomecdata(homeCData);
        return viewDataBinding.getRoot();
    }


    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        homeCData = new HomeCData();
        GeneralTopTitleData generalTopTitleData = new GeneralTopTitleData();
        generalTopTitleData.title.set("消息");
        generalTopTitleData.isshow.set(false);
        homeCData.generaldata.set(generalTopTitleData);
        viewDataBinding.setHomecdata(homeCData);

        new PageHomeCService().RequestMesgList(this);

    }

    @Override
    public void OnMessageList(List<MessageListItemViewData> data) {
        System.out.println("数据");
        System.out.println(data.size());
        MessageListData messageListData = new MessageListData();
        messageListData.listitemdata.set(data);
        homeCData.messagedata.set(messageListData);

    }
}
